package com.example.tanwei.controller;

import com.example.tanwei.service.MailService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Random;

@RestController
@RequestMapping("/email")
public class MailController {
    @Autowired
    private MailService mailService;

    @GetMapping("/getEmail")
    public String getCheckCode(@Param("email") String email){
        String checkCode = String.valueOf(new Random().nextInt(888888)+10000);
        String message = "验证码：" + checkCode;
        System.out.println(message);
        mailService.sendCheckCode(email,"注册验证码",checkCode);
        return checkCode;
    }
}
